package saima;

import java.util.*;

/**
 * @author MaoLin Wang
 * @date 2020/4/1623:13
 */
public class addCollection {
    public static void main(String[] args) {
        Scanner scanner=new Scanner(System.in);
        while (scanner.hasNext()){
            Set<Integer> list1;
            int size1=scanner.nextInt();
            int size2=scanner.nextInt();
            list1=new HashSet<Integer>(size1+size2);

            for (int i = 0; i < (size1); i++) {
                list1.add(scanner.nextInt());

            }
            for (int i = 0; i < size2; i++) {
                list1.add(scanner.nextInt());
            }

            Object[] objects = list1.toArray();

            Arrays.sort(objects);
            for (int i = 0; i < objects.length; i++) {
                System.out.print(objects[i]+" ");
            }
        }
    }

}
